/*
 * Copyright (C) 2010 Peter Schönhofen
 *
 * This file is part of the Akkad Compiler Framework.
 *
 * The Akkad Compiler Framework is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */

package hu.anaxo.akkad.processor

import util.parsing.input.Reader

/**
 * Reader for tokens
 *
 * @param tokens
 */

class TokenReader(tokens: List[Token]) extends Reader[Token] {

  /**
   * Examine whether reader is at end of tokens
   *
   * @return true if there are no more tokens
   */

  def atEnd() = tokens.isEmpty

  /**
   * Get first token
   *
   * @return first token
   */

  def first() = tokens.head

  /**
   * Get position of the first token
   */

  def pos() = tokens.head.pos

  /**
   * Get reader for the rest of tokens
   *
   * @return reader for the rest of tokens
   */

  def rest() = new TokenReader(tokens.tail)
}